import { Body, Controller, Inject, Post } from "@midwayjs/core";
import { ToolService } from "../service/tool.service";
import { RespInfo } from "../types/common.type";


@Controller('/tool')
export class ToolController {

  @Inject()
  toolService: ToolService;


  @Post('/add')
  async add(@Body() info: { user: string, logo: string, href: string, title: string, type: string, remark: string }): Promise<RespInfo> {
    const { user, logo, href, title, type, remark } = info;
    return await this.toolService.add(user, logo, href, title, type, remark)
  }

  @Post('/updated')
  async updated(@Body() info: { uid: string, logo: string, href: string, title: string, type: string, remark: string }): Promise<RespInfo> {
    const { uid, logo, href, title, type, remark } = info;
    return await this.toolService.updated(uid, logo, href, title, type, remark)
  }

  @Post('/delete')
  async delete(@Body() info: { uid: string }): Promise<RespInfo> {
    const { uid } = info;
    return await this.toolService.delete(uid)
  }

  @Post('/list')
  async list(@Body() info: { type?: string }): Promise<RespInfo> {
    const { type } = info;
    return await this.toolService.list(type)
  }

}